//
//  DBBottomView.swift
//  大波微博swift
//
//  Created by 大波 on 16/3/5.
//  Copyright © 2016年 zhaojin. All rights reserved.
//

import UIKit

class DBBottomView: UIView {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override init(frame: CGRect) {
        
        super.init(frame: frame)
        
        prepareUI()
    }
    
    private func prepareUI() {
        
        addSubview(forwardButton)
        
        addSubview(commentButton)
        
        addSubview(likeButton)
        
        addSubview(separatorViewFirst)
        
        addSubview(separatorViewSecond)
        
        addConstraint()
    }
    
    private func addConstraint() {
        
//        let width = UIScreen.width / 3
        
        let multipliedBy = 1 / 3.0
        
        forwardButton.snp_makeConstraints { (make) -> Void in
            
//            make.top.leading.bottom.equalTo(self)
//            
//            make.width.equalTo(width)
            
            
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            
//            make.top.bottom.equalTo(forwardButton)
//            
//            make.leading.equalTo(forwardButton.snp_trailing)
//            
//            make.width.equalTo(width)
            
            
            make.leading.equalTo(forwardButton.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        likeButton.snp_makeConstraints { (make) -> Void in
            
//            make.top.bottom.equalTo(forwardButton)
//            
//            make.leading.equalTo(commentButton.snp_trailing)
//            
//            make.width.equalTo(width)
            
            
            make.leading.equalTo(commentButton.snp_trailing)
            make.top.trailing.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        separatorViewFirst.snp_makeConstraints { (make) -> Void in
            
//            make.leading.equalTo(forwardButton.snp_trailing)
//            
//            make.top.bottom.equalTo(self)
            
            
            make.centerX.equalTo(forwardButton.snp_trailing)
            make.centerY.equalTo(forwardButton)
        }
        
        separatorViewSecond.snp_makeConstraints { (make) -> Void in
            
//            make.leading.equalTo(commentButton.snp_trailing)
//            
//            make.top.bottom.equalTo(self)
            
            
            make.centerX.equalTo(commentButton.snp_trailing)
            make.centerY.equalTo(commentButton)
        }
    }
    
    // MARK: - 懒加载
    
    /// 转发
    private lazy var forwardButton: UIButton = UIButton(imageName: "timeline_icon_retweet", title: "转发")
    
    /// 评论
    private lazy var commentButton: UIButton = UIButton(imageName: "timeline_icon_comment", title: "评论")
    
    /// 赞
    private lazy var likeButton: UIButton = UIButton(imageName: "timeline_icon_unlike", title: "赞")
    
    /// 分割线1
    private lazy var separatorViewFirst: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    
    /// 分割线2
    private lazy var separatorViewSecond: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
}












